
#ifndef SessionPanel_H
#define SessionPanel_H

#include <wx/event.h>
#include <wx/richtext/richtextctrl.h>
#include <wx/artprov.h>
#include <wx/fontdlg.h>
#include <wx/progdlg.h>
#include <wx/splitter.h>

#include "tux.h"

#include "FileTransferEntry.h"

class MsnContact;
class MsnSession;

struct InstantMessageItem;

class InstantMessage;
class InviteMessage;

class MessengerPanel;

class SessionEditor;
class SessionViewer;

class FileTransferEvent;
class FileTransferPanel;

class SessionPanel : public wxPanel
{
friend class MessengerPanel;
friend class SessionNotebook;

friend class SessionViewer;

private:
    //ChatEditor* m_ChatCtrl;
	MessengerPanel* messengerPanel;

private:

	SessionEditor* sessionEditor;
    SessionViewer* sessionViewer;

	wxSplitterWindow* ftSplitter;
	FileTransferPanel* ftPanel;

private:
	wxString contact;
    MsnSession* session;

    wxFont m_DefaultFont;
    wxTextAttr greyStyle;
	wxTextAttr infoStyle;
    wxTextAttr failStyle;

    wxRichTextAttr m_UrlStyle;

    wxTextAttr messageStyle; 

	bool newMsgFlag;

public:
    SessionPanel(MessengerPanel* mp, MsnSession* ms);
    virtual ~SessionPanel();

	void UpdateUIText();

    void SetMessageStyle(wxTextAttr& attr){messageStyle = attr;}

    void SetContact(const wxString& passport){contact = passport;}
    wxString GetContact(){return contact;}

    MsnSession* GetSession(){return session;}
	void AttachSession(MsnSession* ms);

	bool IsForContact(const wxString& passport);

	void OnContactStatusChanged(MsnContact* contact);

	void EnableChatCtrl(bool b);

	bool HasNewMessage(){return newMsgFlag;}
	void SetNewMessage(bool b){newMsgFlag = b;}

	void ShowFileTransferPanel(bool b);

public:
    void AppendInstantMessage(const wxString& passport, const wxString& content);

	void AppendInstantMessage(const wxString& passport, const wxString& content, const wxFont& font, const wxColour& color);

	//void AppendInstantMessage(const InstantMessage& msg);

    void AppendInstantMessageFailed(const wxString& content);

	void AppendFileInviteSent(FileTransferEntry* item);
    void AppendFileInviteReceived(FileTransferEntry* item);

	void AppendFileTransferFinished(FileTransferEntry* item);
	void AppendFileTransferFailed(FileTransferEntry* item);

	void AppendFileTransferText(const wxString& info);

private:
    void AppendURL(const wxString& urlText, const wxString& urlLink);

protected:
	void OnContextMenu(wxContextMenuEvent& event);
    void OnTextUrl(wxTextUrlEvent& event);
    void OnToolFont(wxCommandEvent& event);
    void OnToolFile(wxCommandEvent& event);

	void OnInstantMessageReceived(wxCommandEvent& event);

	void OnFileInviteSent(wxCommandEvent& event);
	void OnFileInviteReceived(wxCommandEvent& event);

	void OnFileTransferStarted(wxCommandEvent& event);
	void OnFileTransferUpdated(FileTransferEvent& event);
	void OnFileTransferDone(wxCommandEvent& event);
	void OnFileTransferFailed(wxCommandEvent& event);
	void OnFileTransferCancelled(wxCommandEvent& event);

DECLARE_EVENT_TABLE()
};

#endif

